/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Security;

import Security.Input_regex_checks;
import Models.*;
import sun.org.mozilla.javascript.internal.ast.LetNode;
/**
 *
 * @author Don
 */
public class Master_check {
    
     public boolean dvdcheck(DVDs dvd)
     {
         
         int counter = 0;
         
         Input_regex_checks dvdcheck = new Input_regex_checks();
         
         if(dvdcheck.lettersNumbersSpace(dvd.getTitle()))
           { counter++; System.out.print(1);}
         if(dvdcheck.lettersOnly(dvd.getGenre()))
           { counter++; System.out.print(2);}
         if(dvdcheck.dateOnly(dvd.getReleaseDate()))
            { counter++; System.out.print(3);}
         if(dvdcheck.floatOnly(String.valueOf(dvd.getPrice())))
           { counter++; System.out.print(4);}
         if(dvdcheck.numbersOnly(String.valueOf(dvd.getNumDiscs())))
             { counter++; System.out.print(5);}
         if(dvdcheck.lettersNumbersSpace(dvd.getSynopsis()))
            { counter++; System.out.print(6);}
         
         if(counter==6)
             return true;
         else
             return false;

     }
     
     public boolean bookcheck (Books book){
         
         int counter = 0;
         
         Input_regex_checks bookcheck = new Input_regex_checks();

         if(bookcheck.lettersNumbersSpace(book.getTitle()))
         { counter++; System.out.print(1);}
         if(bookcheck.numbersOnly(book.getIsbn()))
          { counter++; System.out.print(2);}
         if(bookcheck.lettersNumbersSpace(book.getAuthor()))
           { counter++; System.out.print(3);}
         if(bookcheck.lettersOnly(book.getPublisher()))
          { counter++; System.out.print(4);}
         if(bookcheck.lettersOnly(book.getCategory()))
           { counter++; System.out.print(5);}
         if(bookcheck.floatOnly(String.valueOf(book.getPrice())))
            { counter++; System.out.print(6);}
         if(bookcheck.lettersNumbersSpace(book.getSynopsis()))
           { counter++; System.out.print(7);}
         System.out.print("end2");
         if(counter==7)
             return true;
         else
             return false; 

     }
     
     public boolean accountCheck (Account account,String repassword){
         int counter = 0;
         
        Input_regex_checks accountCheck = new Input_regex_checks();
         
         if(accountCheck.lettersOnly(account.getFirstName()))
             { counter++; System.out.print(1);}
         if(accountCheck.lettersOnly(account.getMidName()))
             { counter++; System.out.print(2);}
         if(accountCheck.lettersOnly(account.getLastName()))
             { counter++; System.out.print(3);}
         if(accountCheck.isValidEmailAddress(account.getEmail()))
             { counter++; System.out.print(4);}           
         if(accountCheck.lettersNumbers(account.getUsername()))
             { counter++; System.out.print(5);}
         if(accountCheck.lettersNumbers(account.getPassword()))
             { counter++; System.out.print(6);}
         if(accountCheck.lettersOnly(account.getCardName()))
             { counter++; System.out.print(7);}
         if(accountCheck.numbersOnly(account.getCardNum()))
             { counter++; System.out.print(8);}
         if(accountCheck.lettersNumbers(account.getCardType()))
             { counter++; System.out.print(9);}
         if(accountCheck.dateOnly(account.getCardExp()))
             { counter++; System.out.print(10);}
         if(accountCheck.lettersNumbers(repassword))
            { counter++; System.out.print(11);}
         
         
         if (counter==11)
             return true;
         else 
             return false; 
         //if(accountCheck.lettersOnly(account.getPassword()))
     }
     
     
     public boolean audioCheck (Audio audio){
         int counter = 0;
         
        Input_regex_checks audiocheck = new Input_regex_checks();
         
         
         if(audiocheck.lettersOnly(audio.getTitle()))
             counter++;
         if(audiocheck.numbersOnly(audio.getLength()))
             counter++;
         if(audiocheck.lettersOnly(audio.getRecordingArtist()))
             counter++;
         if(audiocheck.lettersOnly(audio.getProducer()))
             counter++;
         if(audiocheck.lettersOnly(audio.getGenre()))
             counter++;
         if(audiocheck.lettersOnly(audio.getLabel()))
             counter++;
         if(audiocheck.floatOnly(String.valueOf(audio.getPrice())))
             counter++;
         if(audiocheck.lettersOnly(audio.getSynopsis()))
             counter++;
         
         if (counter == 8)
         return true;
         else
         return false;
     }
    
     
     public boolean magCheck (Magazines mag){
         int counter = 0;
        Input_regex_checks magcheck = new Input_regex_checks();
         
         if(magcheck.lettersOnly(mag.getTitle()))
             counter++;
         if(magcheck.lettersOnly(mag.getIssue()))
             counter++;
         if(magcheck.lettersOnly(mag.getEditor()))
             counter++;
         if(magcheck.lettersNumbers(mag.getFrequency()))
             counter++;
         if(magcheck.floatOnly(String.valueOf(mag.getPrice())))
             counter++;
         if(magcheck.lettersNumbersSpace(mag.getSynopsis()))
             counter++;
         
         if (counter == 6)
         return true;
         else 
             return false;
                 
     }
     
     public boolean loginCheck (String username, String password){
         int counter = 0;
         Input_regex_checks logincheck = new Input_regex_checks();
         
         if(logincheck.lettersNumbers(username))
             counter++;
         if(logincheck.lettersNumbers(password))
             counter++;
         
         if(counter == 2)
         return true;
         else 
             return false;
     }
     
     public boolean registerCheck (Account account, String rePassword){ //, Address address, String rePassword){
         int counter = 0;
        Input_regex_checks checker = new Input_regex_checks();
         
         if(checker.lettersOnly(account.getUsername()))
             counter++;
         if(checker.lettersOnly(account.getPassword()))
             counter++;
         if(checker.lettersOnly(rePassword))
             counter++;
         if(checker.isValidEmailAddress(account.getEmail()))
             counter++;
         if(checker.lettersOnly(account.getFirstName()))
             counter++;
         if(checker.lettersOnly(account.getMidName()))
             counter++;
         if(checker.lettersOnly(account.getLastName()))
             counter++;
         if(checker.lettersOnly(account.getCardName()))
             counter++;
         if(checker.numbersOnly(account.getCardNum()))
             counter++;
         if(checker.lettersOnly(account.getCardType()))
             counter++;
         if(checker.dateOnly(account.getCardExp()))
             counter++;
         
         /*
         if(checker.numbersOnly(address.getHouseNo()))
             counter++;
         if(checker.lettersOnly(address.getStreet()))
             counter++;
         if(checker.lettersOnly(address.getSubdivision()))
             counter++;
         if(checker.numbersOnly(address.getPostalCode()))
             counter++;
         if(checker.lettersOnly(address.getCountry()))
             counter++;*/
         
         //if(counter == 16)
         if(counter==11)
         return true;
         else
             return false;
     }
}
